﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="register.aspx.cs" Inherits="register"      EnableViewState="false" %>
<!DOCTYPE html>
<html>
<head>
    <title>用户注册</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"
        charset="utf-8" />
    <link href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" rel="stylesheet"
        type="text/css" />
    <%--<link href="jquery.mobile-1.3.2.css" rel="stylesheet" type="text/css" />--%>
    <link href="mobiscroll.custom-2.5.0.min.css" rel="stylesheet" type="text/css" />
    <script src="http://code.jquery.com/jquery-1.11.2.min.js" type="text/javascript"></script>
    <%--<script src="jquery-1.11.2.min.js" type="text/javascript"></script>--%>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js" type="text/javascript"></script>
    <%--<script src="jquery.mobile-1.3.2.js" type="text/javascript"></script>--%>
    <link href="Micro-Website.css" rel="stylesheet" type="text/css" />
    <link href="styles.css" rel="stylesheet" type="text/css" />
    <link href="photoswipe.css" rel="stylesheet" type="text/css" />
    <script src="klass.min.js" type="text/javascript"></script>
    <script src="code.photoswipe-3.0.5.min.js" type="text/javascript"></script>
    <script src="mobiscroll.custom-2.5.0.min.js" type="text/javascript"></script>
    <script src="xxl.base.js" type="text/javascript"></script>
    <script type="text/javascript">
        function onBridgeReady() {
            WeixinJSBridge.call('hideToolbar');
            WeixinJSBridge.call('hideOptionMenu');
        }
        if (typeof WeixinJSBridge == "undefined") {
            if (document.addEventListener) {
                document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
            } else if (document.attachEvent) {
                document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
            }
        } else {
            onBridgeReady();
        }
    </script>
</head>
<body>
    <div>
        <section data-role="page" id="register_main">
            <div data-role="content" id="register_content">
                <fieldset data-role="controlgroup">
                    <legend>
                    <img src="images/MemInformation.png" alt="" />
	               	    用户注册
                    </legend>
                    <label for="memname"><span style="color:red;">*</span>用户姓名</label>
                    <input type="text" id="memname" placeholder="请输入您的姓名" runat="server"/>
                   <label for="telnumber"> <span style="color:red;">*</span>手机号码</label>
                    <input type="text" id="telnumber" placeholder="请输入您的手机号码" runat="server" />
                    <label for="txtRecommended" id="labRecommended"  runat="server">推荐人</label>
                    <input type="text" id="txtRecommended"  placeholder="请输入推荐人卡号" runat="server" />
                     <label for="telnumber"><span style="color:red;">*</span>验证码</label>
                     <input type="text" id="YanZhengMa" placeholder="请输入下面的验证码" runat="server"/>
                     <input type="hidden" id="hidReferrerMemId" runat="server" />
                     <img id="Login_ValImg" src="" style="height: 30px; width: 90px; border: 0" alt=""  title="看不清？换一个" align="top" />
                     
                     <a href="javascript:void(0);" onclick="javascript:Login_ChangeValImg();">
                     <span style="color:red;font-size:12px;">看不清点我</span>
                     </a>
                     <br /><br />
                    <label for="memname"><span style="color:red;font-size:12px;">温馨提示：密码默认为手机号码后六位</span></label>
                    <input type="hidden" id="OpenID" runat="server" />
                    <input type="hidden" id="Url" runat="server" />
                     <input type="hidden" id="hidTJR"  value="0" runat="server" />
                    <%--推荐人--%>
                    <input type="hidden" id="Recommended" value="0" runat="server" />
                      <input type="hidden" id="hidtf" value="0" runat="server" />
                    <a href="#" data-role="button" data-theme="e"  id="registerSumbit">立即注册</a>
                    <a href="#index" data-role="button" data-theme="b" style="display:none;" id="goBack">返回首页</a>
                </fieldset>
            </div>
            <script type="text/javascript">
                $(document).ready(function () {
                    Login_ChangeValImg();
                    if ($("#hidtf").val() == "0") {
                        //判断该微信是否有注册，有注册直接跳转到首页
                        $.get("../Service/AjaxService.ashx?Method=GetMemWeiXinCard",
                    {
                        "OpenID": $.trim($("#OpenID").val())
                    }, function (text) {
                        if (text == "1") {
                            alert("你已经是微信会员了");
                            location.href = $("#Url").val();
                        }
                    }, "text");
                    }
                    //提交事件
                    $("#registerSumbit").click(function () {
                        var OpenID = "";
                        if ($("#hidtf").val() == "0") {
                            OpenID = $.trim($("#OpenID").val());
                            if (OpenID == "") {
                                alert("非法操作！");
                                return;
                            }
                        }
                        var memname = $.trim($("#memname").val());
                        var telnumber = $.trim($("#telnumber").val());
                        var txtRecommended = $.trim($("#txtRecommended").val()); //推荐人卡号
                        var YanZhengMa = $.trim($("#YanZhengMa").val());
                        var hidTJR = $("#hidTJR").val();
                        if (memname == "") {
                            alert("姓名不可以为空！");
                            return;
                        }
                        if (telnumber != "" && !telnumber.IsMobile()) {
                            alert("您输入的手机号码格式有误");
                            return;
                        }
                        if (hidTJR != "1") {
                            {
                                if (txtRecommended != "") {
                                    var re = /^[1-9]+[0-9]*]*$/;
                                    if (!re.test(txtRecommended)) {
                                        alert("推荐人会员卡号是由数字组成的");
                                        return;
                                    }
                                    if (txtRecommended.length < 4) {
                                        alert("推荐人会员卡号必须4~20位");
                                        return;
                                    }
                                }
                            }
                            $.get("../Service/AjaxService.ashx?Method=WX_Register",
                    {
                        "MemName": memname,
                        "telnumber": telnumber,
                        "referrerMemId": $("#Recommended").val(), //推荐人ID
                        "OpenID": OpenID,
                        "txtRecommended": txtRecommended, //推荐人卡号
                        "YanZhengMa": YanZhengMa,
                        "hidtf": $("#hidtf").val()
                    }
                    , function (text) {
                        if (text == "-2") {
                            alert("系统错误，联系管理员！");
                            $("#memname").val("");
                            $("#pass1").val("");
                            $("#pass2").val("");
                            $("#telnumber").val("");
                        }
                        else if (text == "-1") {
                            alert("该手机号已注册！");
                            $("#memname").val("");
                            $("#pass1").val("");
                            $("#pass2").val("");
                            $("#telnumber").val("");
                        }
                        else if (text == "-3") {
                            alert("验证码错误！");
                        }
                        else if (text == "-4") {
                            alert("推荐人卡号不存在！");
                        }
                        else if (text == "-5") {
                            alert("系统错误！");
                        }
                        else if (text == "-6") {
                            alert("此微信已经绑定账号，不能注册新账号！");
                        }
                        else if (text == "-9") {
                            alert("呵呵！");
                        }
                        else if (text == "-7") {
                            alert("短信验证码错误,请重新获取！");
                        }
                        else {
                            alert("注册成功");
                            location.href = "index.aspx";
                        }
                        $("#goBack").click();
                    }, "text")
                        }
                    });
                });

                function ChangeValImg() {
                    $("#Login_ValImg").attr("src", "../Service/ValidateImage.ashx?" + GetGuid());
                }
                function Login_ChangeValImg() {
                    /*自动刷新验证码*/
                    ChangeValImg();
                    setTimeout("Login_ChangeValImg()", 60 * 1000 * 3);
                }
                function GetGuid() {
                    var now = new Date();
                    var year = now.getFullYear(); //getFullYear getYear
                    var month = now.getMonth();
                    var date = now.getDate();
                    var day = now.getDay();
                    var hour = now.getHours();
                    var minu = now.getMinutes();
                    var sec = now.getSeconds();
                    var mill = now.getMilliseconds();
                    month = month + 1;
                    if (month < 10) month = "0" + month;
                    if (date < 10) date = "0" + date;
                    if (hour < 10) hour = "0" + hour;
                    if (minu < 10) minu = "0" + minu;
                    if (sec < 10) sec = "0" + sec;
                    var guid = month + date + hour + minu + sec + mill;
                    return guid;
                }
            </script>
            <footer data-role="footer" data-position="fixed" id="register_footer">
            </footer>
        </section>
    </div>
</body>
</html>



